#include <iostream>
using namespace std;
int main() {
  auto encode = [](auto &self) -> string {
    char ch;
    string res;
    while (cin >> ch) {
      if (ch == '[') {
        int x;
        cin >> x;
        string temp = self(self);
        while (x--) res += temp;
      } else if (ch == ']') {
        return res;
      } else {
        res += ch;
      }
    }
    return res;
  };
  cout << encode(encode) << endl;
}